package com.dragon.repository.domain.vo;

import com.dragon.common.model.Update;
import com.dragon.repository.entity.RepairProduct;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import com.dragon.common.util.BeanUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.Date;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class RepairProductVO {

    private static final long serialVersionUID = 1L;

    private Integer id;

    @ApiModelProperty(value = "报价的产品id")
    private Integer productId;

    @ApiModelProperty(value = "维修单id")
    private Integer repairId;

    @ApiModelProperty(value = "退货数量")
    private Integer num;

    @ApiModelProperty(value = "维修数量")
    private Integer rejectNum;

    @ApiModelProperty(value = "已发货数量")
    private Integer deliverNum;

    @ApiModelProperty(value = "实际维修数量")
    private Integer rejectRealityNum;

    @ApiModelProperty(value = "维修状态：0未完成，1已维修")
    private Integer status;

    @ApiModelProperty(value = "更新时间")
    private Date updateTime;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static RepairProduct convert(RepairProductVO vo) {
        RepairProduct entity = new RepairProduct();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<RepairProduct> convertList(List<RepairProductVO> list) {
        List<RepairProduct> resultList = new ArrayList<>();
        for (RepairProductVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
